package com.mdlib.helper.ui.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljlib.core.util.common.TimeUtils;
import com.ljlib.help.R;
import com.mdlib.helper.model.entity.OrderEntity;

import java.util.List;

/**
 * 作者：HQY on 16/11/14 15:21
 * 邮箱：hqy_xz@126.com
 */

public class VicinityOrderAdapter extends BaseQuickAdapter<OrderEntity> {


    public VicinityOrderAdapter(List<OrderEntity> data) {
        super(R.layout.item_vicinity_order, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, OrderEntity order) {

        baseViewHolder.setText(R.id.tv_service_money, "￥" + order.getServiceMoney())
                .setText(R.id.tv_send_order_name, order.getRemark())
                .setText(R.id.tv_send_order_postaddr, order.getPostAddr());


        if (order.getHopeTime() == 0) {
            baseViewHolder.setText(R.id.tv_send_order_success_time, mContext.getResources().getString(R.string.generic_order_success_time));
        } else {
            baseViewHolder.setText(R.id.tv_send_order_success_time, TimeUtils.milliseconds2String(Long.valueOf(order.getHopeTime()) * 1000, TimeUtils.SUCCESS_MONTH));
        }
        if (order.getOrderStatus() == 0) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_zore));
        } else if (order.getOrderStatus() == 1) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_one));
        } else if (order.getOrderStatus() == 2) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_two));
        } else if (order.getOrderStatus() == 5) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_five));
        } else if (order.getOrderStatus() == 6) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_six));
        } else if (order.getOrderStatus() == 7) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_seven));
        } else if (order.getOrderStatus() == 8) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_eight));
        } else if (order.getOrderStatus() == 9) {
            baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_order_type_night));
        }

        TextView orderType = baseViewHolder.getView(R.id.tv_order_type);
        TextView sendOrderType = baseViewHolder.getView(R.id.tv_send_order_type);
        if (order.getBusType() == 1) {
            if (order.getOrderStatus() == 3) {
                baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_agency_order_type_three));
            } else if (order.getOrderStatus() == 4) {
                baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_agency_order_type_four));
            }
            Drawable agency = mContext.getResources().getDrawable(R.drawable.iv_details_agecy);
            agency.setBounds(0, 0, agency.getMinimumWidth(), agency.getMinimumHeight());
            orderType.setCompoundDrawables(null, agency, null, null);
            orderType.setText(mContext.getResources().getString(R.string.send_home_agency));

            Drawable agencys = mContext.getResources().getDrawable(R.drawable.vicinity_order_class);
            agencys.setBounds(0, 0, agencys.getMinimumWidth(), agencys.getMinimumHeight());
            sendOrderType.setCompoundDrawables(agencys, null, null, null);
            sendOrderType.setText(order.getHandleType());
            sendOrderType.setVisibility(View.VISIBLE);

        } else if (order.getBusType() == 2) {
            Drawable minnetoka = mContext.getResources().getDrawable(R.drawable.iv_details_minnetonka);
            minnetoka.setBounds(0, 0, minnetoka.getMinimumWidth(), minnetoka.getMinimumHeight());
            orderType.setCompoundDrawables(null, minnetoka, null, null);
            sendOrderType.setVisibility(View.GONE);
            orderType.setText(mContext.getResources().getString(R.string.send_home_minnetonka));
            if (order.getOrderStatus() == 3) {
                baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_minn_order_type_three));
            } else if (order.getOrderStatus() == 4) {
                baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_minn_order_type_four));
            }
        } else if (order.getBusType() == 3) {
            if (order.getOrderStatus() == 3) {
                baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_take_order_type_three));
            } else if (order.getOrderStatus() == 4) {
                baseViewHolder.setText(R.id.tv_send_order_type_tips, mContext.getResources().getString(R.string.generic_take_order_type_four));
            }
            Drawable take = mContext.getResources().getDrawable(R.drawable.iv_details_take);
            take.setBounds(0, 0, take.getMinimumWidth(), take.getMinimumHeight());
            orderType.setCompoundDrawables(null, take, null, null);
            orderType.setText(mContext.getResources().getString(R.string.send_home_take));
            Drawable takes = mContext.getResources().getDrawable(R.mipmap.vicinity_order_take);
            takes.setBounds(0, 0, takes.getMinimumWidth(), takes.getMinimumHeight());
            sendOrderType.setCompoundDrawables(takes, null, null, null);
            sendOrderType.setText(order.getGetAddr());
            sendOrderType.setVisibility(View.VISIBLE);
        } else if (order.getBusType() == 4) {

        }


    }
}
